﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data.Linq;

namespace Radar {

    public class RadarServiceLocal : IRadarServiceLocal {

        private string connString = @"Data Source=localhost;Initial Catalog=Radar;Integrated Security=true";

        public RadarServiceLocal() { }

        public void StoreCapture(Capture c, List<Image> images) {
            DataContext dc = new DataContext(connString);
            Table<Capture> tc = dc.GetTable<Capture>();
            tc.InsertOnSubmit(c);
            dc.SubmitChanges();
            images.ForEach(i => i.captureId = c.id);
            dc = new DataContext(connString);
            Table<Image> ti = dc.GetTable<Image>();
            ti.InsertAllOnSubmit(images);
            dc.SubmitChanges();
        }
    }
}
